define(['zepto', 'butterfly/view','../../bsl',
    'text!./camera_image.html'
], function($, View, bsl, camera_image) {
    var me = null;

    var view = View.extend({
        events: {

            // ！！！！ 由于 引入 touch.js 后，tap事件会变成双击，所以 本页面内不能使用tap，用click代替。
            "tap .openDoc" : "openDoc",
            "tap #back" : "back",

      
        },
        render: function() {
            me = this;
        },

        onShow: function() {

            // 绑定自定义事件 滑动切换日历等           


        },
         w:null,
// H5 bsl事件处理
        bslReady:function (){
            w=bsl.nativeUI.showWaiting();
        }
        if(window.bsl){
            bslReady();
        }else{
            document.addEventListener("bslready",bslReady,false);
        },
        imgLoaded:function () {
            w&&(w.close(),w=null);
            var b = document.body;
            var img = document.getElementById("img");
            var pb = b.clientHeight/b.clientWidth,
            pi = img.clientHeight/img.clientWidth;
            if ( pb > pi ) {
                img.style.width = "100%";
            } else {
                img.style.height = "100%";
            }
            b.style.lineHeight = b.clientHeight+"px";
        },
        imgError:function (){
            w&&(w.close(),w=null);
            document.getElementById("img").style.display = "none";
            bsl.nativeUI.alert( "无效的图片资源", function(){
                this.back();
            } );
        },
        loadMedia:function (src){
            document.getElementById("img").src=src;
        },
         back : function(e){
            window.history.go(-1);
        },
        openDoc:function(){
            window.butterfly.navigate('/doc/events.html', {
                trigger: true
            });


        },
                
    });
    return view;
});
